package com.oocl.webmvc_2.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.oocl.webmvc_2.pojo.Customer;
import com.oocl.webmvc_2.service.CustomerService;

public class CustomerServiceImpl implements CustomerService {
	private List<Customer> list = new ArrayList<Customer>();
	public Customer addCustomer(Customer c) {
		synchronized (list) {
			list.add(c);
		}
		return c;
	}

	public List<Customer> findAllCustomers() {
		return list;
	}

	public Customer deleteCustomer(String id) {
		Customer delCustomer = null;
		for(int i = 0; i < list.size(); i++){
			System.out.println(list.get(i).getId() + " " + id);
			if(list.get(i).getId().equals(id)){
				list.remove(i);
			}
		}
		return delCustomer;
	}

}
